# -*- coding: utf-8 -*-
import telnetlib,time,sqlite3,MySQLdb,ping
from threading import Thread
from Queue import Queue
from time import sleep

timeout=1
count = 1
psize = 64
dest_addr="172.16.100.31"
# 单个ping测试
# ping.verbose_ping(dest_addr)
# print ping.quiet_ping(dest_addr,timeout,count,psize)


# 从mysql的rnd表取ndip数据
conn=MySQLdb.connect(host="172.16.100.31",user="root",passwd="admin",db="rainbow_3_0")
cursor=conn.cursor()
# cursor.execute("select dscfgnwipaddr from rnd order by dscfgnwipaddr desc limit 10")
cursor.execute("select dscfgnwipaddr from rnd order by dscfgnwipaddr")
nds=cursor.fetchall()
cursor.close()
conn.close()
print len(nds)
for x in nds:
	lost,mrtt,lrtt=ping.quiet_ping(x[0],timeout,count,psize)
	if lost<>0:
		print x[0],lost